package StudyCode.summary.mycollection;

import java.util.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class RemoveDuplicatesFromArrayListOfLong {
	public static ArrayList<Long> removeDuplicates(ArrayList<Long> a_master) {
		ArrayList<Long> a = new ArrayList<Long>(a_master);
		Set<Long> set = new HashSet<Long>();
		List<Long> newList = new ArrayList<Long>();
		for (Iterator<Long> iter = a.iterator(); iter.hasNext(); ) {
			Long element = iter.next();
			if (set.add(element))
				newList.add(element);
		}
		a.clear();
		a.addAll(newList);
		return a;
	}
}
